package cn.itcast.mobile;


import cn.itcast.constant.MessageConstant;
import cn.itcast.domain.SetMeal;
import cn.itcast.entity.Result;
import cn.itcast.service.MobileSetmealService;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import java.util.List;


@RestController
@RequestMapping("/setmeal_mobile")
public class SetmealDetailController {

    @Reference
    private MobileSetmealService mobileSetmealService;

    @RequestMapping("/getSetmeal")
    public Result findSetmealById(){
        try {
            List<SetMeal> setMeals = mobileSetmealService.findAllSetMeal();
            return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS,setMeals);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.GET_SETMEAL_LIST_FAIL);
        }
    }

    @RequestMapping("/findDataById")
    public Result findAllDatasById(Integer id){

        try {
            SetMeal setMealList = mobileSetmealService.findAllData(id);
            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setMealList);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false,MessageConstant.QUERY_SETMEAL_FAIL);
        }
    }




}
